{{include template('public/header','admin')}}
<style>
    label {
        display: block;
        max-width: 100%;
        margin-bottom: 0px;
        font-weight: 300;
    }
</style>
<body>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <div class="page-header">

                </div>
                <div class="search">

                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <fieldset>
                    <legend>设置【{{$role.title}}】角色权限</legend>
                    <form method="post" action="/admin/role/role_priv" class="form-inline" role="form">
                        <input type='hidden' name='roleid' value="{{$role['roleid']}}" />
                        <table class="table table-border table-bordered table-bg table-hover permission">
                            <thead>
                                <tr class="text-c">
                                    <th class="text-l">权限名称</th>
                                </tr>
                            </thead>
                            <tbody>
                                {{$menus}}
                            </tbody>
                            <tr>
                                <td colspan="15">
                                    <div style="text-align: left;">
                                        <input type="submit" class="btn" name="sendsubmit" value="提交" />
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </form>
                </fieldset>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function checknode(obj) {
            var chk = $("input[type='checkbox']");
            var count = chk.length;
            var num = chk.index(obj);
            var level_top = level_bottom = chk.eq(num).attr('level');
            for (var i = num; i >= 0; i--) {
                var le = chk.eq(i).attr('level');
                if (eval(le) < eval(level_top)) {
                    chk.eq(i).attr("checked", 'checked');
                    var level_top = level_top - 1;
                }
            }
            for (var j = num + 1; j < count; j++) {
                var le = chk.eq(j).attr('level');
                if (chk.eq(num).attr("checked") == 'checked') {
                    if (eval(le) > eval(level_bottom))
                        chk.eq(j).attr("checked", 'checked');
                    else if (eval(le) == eval(level_bottom))
                        break;
                } else {
                    if (eval(le) > eval(level_bottom))
                        chk.eq(j).attr("checked", false);
                    else if (eval(le) == eval(level_bottom))
                        break;
                }
            }
        }
    </script>
</body>
</html>

